package main;

import java.util.ArrayList;
import java.util.Collection;

public class FootballTeam {

	private String _name;
	private Collection<Footballer> _players;

	public FootballTeam(String name){
		_players = new ArrayList<Footballer>();
		this._name = name;
	}

	public void hireFootballer(Footballer member){
		if(!_players.contains(member)){
			_players.add(member);

			if(member.getTeam(this) == null)
				member.joinANewTeam(this);
		}
	}

	public void fireFootballer(Footballer member){
		_players.remove(member);
		
		if(member.getTeam(this) != null)
		member.quitTeam(this);
	}
	
	public String toString(){
		return _name;
	}

	public Footballer getPlayer(Footballer player){
		for(Footballer fb : _players){
			if(fb.equals(player))
				return fb;
		}
		return null;
	}

	public String get_name() {
		return _name;
	}

	public void set_name(String _name) {
		this._name = _name;
	}

	public Collection<Footballer> get_members() {
		return _players;
	}

	public boolean equals(Object o){
		if(o instanceof FootballTeam){
			FootballTeam f = (FootballTeam)o;
			if(f._name == this._name)
				return true;	
		}
		return false;
	}		
}
